package com.example.oldkingdom.entities;

import com.example.oldkingdom.activities.Explore;
import com.example.oldkingdom.items.item;

import android.os.Handler;

public class appleTree extends spawner 
{
	public appleTree()
	{
		setVisible(true);
	}
	@Override
	public void onEnterArea()
	{
		active = true;
		new Handler().postDelayed(new Runnable(){ 
            @Override 
            public void run() 
            { 
               if (!active)
            	   return;
               
               if (Explore.Instance.CurrentArea.getAllItems().size() > 5)
            	   return;
               
         	   Explore.Instance.CurrentArea.addItem(item.apple.getName());
         	   Explore.Instance.addDescription("An apple has fallen from the tree");
         	   Explore.Instance.addDescription("");
         	   onEnterArea();
            } 
       },(long)( Math.random() * (maxTime - minTime) + minTime)); 
	}
	@Override
	public void onLeaveArea()
	{
		active = false;
	}
	private float minTime = 5000;
	private float maxTime = 10000;

}
